Config = {
	StateTime:{
		INT: 15,
		REGISTER: 1,
		READY: 1,
        CHOOSE_FIRST_PLAYER: 10,
        SETBOARD: 10,
		TURN_TIME: 5,
		ENDSET: 3,
		RESET: 1,
        ENDGAME: 20
	},
	Const:{
		BOARD_START_ID: 18,
	},
	DebugMode: {
		PAINT: true,
		POSITON: false
	},
	Board: {
		LeftOX: 260,
		LeftOY: 60,
		RightOX: 535,
		RightOY: 230,
		Dx: 26,
		Dy: 16,
		DEBUG_OX: 608,
		DEBUG_OY: 506,
		CELL_WIDTH: 9,
		SPACING: 8
	}
};

Types = {    
    Messages: {
		HELLO: 0,
		WELCOME: 1,
		SPAWN: 2,
		DESPAWN: 3,
        POPULATION: 4,
		LIST: 5,
		WHO: 6,
		UPDATE: 7,
        VIEW: 8,
        PLAY: 9,
        JOIN: 10,
        GAMEACTION: 11,
        GAMEREGISTER: 12,
        TABLELIST: 13,
        WHATTABLE: 14,
        TABLE: 15
    },
	Entities: {
        WARRIOR: 1,
		SOCCER: 2,
		BALL: 3,
		VIEWER: 4,
		MISSED: 5,
		HITTED: 6,
		ONHIT: 7,
		FIRE: 8,
		ONFIRE: 9
	},
    Orientations: {
        UP: 1,
        DOWN: 2,
        LEFT: 3,
        RIGHT: 4
    },
    Gamestates: {
        INIT: 0,
        REGISTER: 1,
        READY: 2,
        CHOOSE_FIRST_PLAYER: 3,
        SETBOARD: 4,
        GAMEPLAY: 5,
        ENDSET: 6,
        RESET: 7,
		ENDGAME: 8
    },
    Gameactions: {
        REGISTER: 0,
        CHOOSE_FIRST_PLAYER: 1,
        SETBOARD: 2,
        TURN: 3
    },
    Clientstates: {
        LOBBY: 0,
        INGAME: 1
    },
	BoardStatus: {
		EMPTY: 0,
		HITTED: 1,
		MISSED: -1,
		DISTROYER: 3,
		PATROL: 4,
		SUBMARINE: 5,
		BATTLESHIP: 6,
		AIRCRAFT_CARRIER: 7
	},
	SetupResult: {
		SUCCESS: 0,
		OVERLAP: 1,
		MISSING: 2,
		REDUNDANT: 3,
		OUT_OF_BOARD: 4,
		INCORRECT_TYPE: 5,
		ERROR: 6
	},
	VValue:{
		BALL_MAX: 10,
		BALL_MIN: 4,
		SOCCER_MAX: 5,
		SOCCER_ONCONTROL: 2,
		MAX_SLOW_TIME: 60
	},
	
	LimitArea:{
		DF:0
	},
	FrameID: {
		Left: 1,
		Right: 2,
		Top: 0,
		Bottom: 3,
		TrunkLeft: 4,
		TrunkRight: 5
	}
};

var kinds = {
    warrior: [Types.Entities.WARRIOR, "player"],
    soccer: [Types.Entities.SOCCER, "soccer"],
    ball: [Types.Entities.BALL, "ball"],
	missed: [Types.Entities.MISSED, "missed"],
	hitted: [Types.Entities.HITTED, "hitted"],
	onhit: [Types.Entities.ONHIT, "onhit"],
	fire: [Types.Entities.FIRE, "fire"],
	onfire: [Types.Entities.ONFIRE, "onfire"],

    getType: function(kind) {
        return kinds[Types.getKindAsString(kind)][1];
    }
};

Types.getKindAsString = function(kind) {
    for(var k in kinds) {
        if(kinds[k][0] === kind) {
            return k;
        }
    }
};

if(!(typeof exports === 'undefined')) {
    module.exports = Types;
}
